#include<termios.h>                                     

#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include <string.h>
#include "interface.h"

void serial_init(int fd) //初始化串口的函数
{
    struct termios options;
    tcgetattr(fd, &options);
    options.c_cflag |= (CLOCAL | CREAD);
    options.c_cflag &= ~CSIZE;
    options.c_cflag &= ~CRTSCTS;
    options.c_cflag |= CS8;
    options.c_cflag &= ~CSTOPB;
    options.c_iflag |= IGNPAR;
    options.c_oflag  = 0;
    options.c_lflag  = 0;
	options.c_cc[VEOL] 	= 1;
	//options.c_oflag |= ONLCR;

    cfsetispeed(&options, B115200); 
    cfsetospeed(&options, B115200);
    tcsetattr(fd, TCSANOW, &options);
}